package com.rpcdemo.client;

import com.rpcdemo.client.impl.CnBlogClientFallback;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * create by yongli on 2021-12-26 07:57
 * 获取报错信息
 */
@Component
public class CnBlogClientFallbackFactory implements FallbackFactory<CnBlogClient> {

    private final CnBlogClientFallback cnBlogClientFallback;

    public CnBlogClientFallbackFactory(CnBlogClientFallback cnBlogClientFallback) {
        this.cnBlogClientFallback = cnBlogClientFallback;
    }

    @Override
    public CnBlogClient create(Throwable throwable) {
        throwable.printStackTrace();
        // 报错后返回该对象对象代替原有对象
        return cnBlogClientFallback;
    }
}
